package com.atguigu.url.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * @version V1.0
 * @author: guangcheng
 * @date: 2021/11/17 15:46
 * @description:
 */
@Component
public class RedisDefUtil {


    @Autowired
    StringRedisTemplate redisTemplate;


    /**
     * 只要做一些约定就不用这么大费周章
     * 调出redis所有的Key
     *
     * @return
     */
    @Deprecated
    public List<String> getRedisKeysToList() {
        ArrayList<String> list = new ArrayList<>();

        Set<String> keys = redisTemplate.keys("*");
        for (String key : keys) {
            list.add(key);
        }

        return list;
    }
}

